/**
 * 弯弯工作组
 */
function friendsreferralInit(url,userId) {
	$("#hidTeamId").hide();
	$.post(url + "referral/getFridensList", {"userId" : userId,"uncheckTeamId" : -2}, function(data) {
		var source = data;
		$('#jqxTree').jqxTree({height : '350px',source : source,width : '147px',theme : 'summer',allowDrag:false});
		$("#teamjqxTree").wjTree({url:url,userId:userId,uncheckTeamId:"-2"});
		$('#jqxTree').on('expand', function (event) {
			var htmlElement = event.args.element;			
			var item = $('#jqxTree').jqxTree('getItem', htmlElement);
			if (item.value=="team") {
				$("#teamjqxTree").wjTree({url:url,userId:userId,uncheckTeamId:item.id});
			} else {	
			}
		});
		$('#jqxTree').on('select', function (event) {
			var htmlElement = event.args.element;			
			var item = $('#jqxTree').jqxTree('getItem', htmlElement);
			if (item.value == "team") {	
			} else {
				$("#hidIsReferralId").val(item.value);
			}
		}); 	
	}, "json");
	$("#qzfSend").click(function(){
		 var items = $('#teamjqxTree').jqxTree('getCheckedItems');
         var checkedItems = new Array();
         $.each(items, function () {                   
             checkedItems[checkedItems.length] = this.value;
         });
         var result="";
         for(var i=0; i<checkedItems.length; i++){
			 result+=checkedItems[i]=="team"?"":checkedItems[i];
			 if(i!=checkedItems.length-1&&checkedItems[i]!="team")
				 result+=",";
         }
         if($("#hidIsReferralId").val()==""){
			 $("#dialogDiv").wjDialog({url:url,content:"请选择好友进行推荐"});
			 return;
         }
         if(result==""){
			$("#dialogDiv").wjDialog({url:url,content:"请选择推荐人"});
			return;
         }
         $("#dynamicShowType").val("hytj");
         $("#hidFriendId").val(result);
		 $('#submitForm').ajaxSubmit({
			url : url+"user/userDynamicAdd/hytj",  
			dataType : "json",  
			type:"POST",
            success : function(data){            	
            	$("#dialogDiv").wjDialog({url:url,content:data.msg});
            },  
            error:function(){  
            	$("#dialogDiv").wjDialog({url:url,content:"系统繁忙请稍后再试"});
           }   
		}); 
	});

}
